/**
 * @(#)RandomUtils.java 2017年4月13日
 * Copyright(C) 2017年4月13日 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.util;


import java.text.DecimalFormat;
import java.util.Random;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * TODO 请加入本类的说明
 * @author <a href="mailto:zhouchao@zhexinit.com" >周超</a>
 * @version 1.0.0
 */
public class RandomUtils {
	public static final Logger LOGGER = LoggerFactory.getLogger(RandomUtils.class);

    public static int getRandomNum(){
    	return (int) (Math.random() * Integer.MAX_VALUE);
    }
    
    
    public static int getRandomNum(int section){
    	return (int) (Math.random() * section);
    }
    
    /**
     * 获取6位随机小数
     * @author <a href="mailto:zhouchao@zhexinit.com" >周超</a>
     * @return
     */
    public static double getRandomDouble(){
    	DecimalFormat df=new DecimalFormat("#0.000000");
		return Double.valueOf(df.format(Math.random()));
    }


    /**
     * 随机排序
     * @author xupengcheng 2018/5/4 14:58
     * @method
     * @param
     * @return
     */
    public static Object[] randomObjs(Object[] objs) {
        if (objs != null && objs.length > 0) {
            Random random = new Random();
            int size = objs.length;
            for (int i = 0; i < size; i++) {
                int p = random.nextInt(size);
                Object tmp = objs[i];
                objs[i] = objs[p];
                objs[p] = tmp;
            }
            random = null;
        }
        return objs;
    }


    public static int getRandomNum(int smallistNum, int biggestNum) {
        Random random = new Random();
        return (Math.abs(random.nextInt()) % (biggestNum - smallistNum + 1))+ smallistNum;
    }


    public static void main(String[] args) {
        Random random = new Random();
        System.out.println(Math.abs(random.nextInt()));
    }
}
